package net.muchine.test.ddd.domain;

import java.math.BigDecimal;

public class Money {
	private BigDecimal amount;
	public String unit;
	
	public Money() {}
	
	public Money(BigDecimal amount) {
		this.amount = amount;
	}
	
	public Money(long amount) {
		this(new BigDecimal(amount));
	}
	
	public Money add(Money added) {
		return new Money(this.amount.add(added.amount));
	}
	
	public Money multiply(int value) {
		return new Money(this.amount.multiply(new BigDecimal(value)));
	}
	
	public boolean isGreaterThan(Money money) {
		return this.amount.compareTo(money.amount) > 0;
	}	

	@Override
	public int hashCode() {
		return this.amount.hashCode();
	}

	@Override
	public boolean equals(Object object) {
		if (this == object) return true;
		
		if (!(object instanceof Money))	return false;
		
		return this.amount.equals(((Money)object).amount);
	}

	@Override
	public String toString() {
		return amount.toString();
	}
}
